#!/bin/bash

basedir=`pwd|tr -d '\n'`

component=urlogging
port=80

deploydir=${basedir}/deployment/${component}
gaedir=${basedir}/ext/gae

htmldir=${basedir}/src/html/${component}
cssdir=${basedir}/src/css/${component}
jsdir=${basedir}/src/js/${component}
pythondir=${basedir}/src/python/${component}

function init()
{
	mkdir -p ${deploydir}
	mkdir -p ${deploydir}/css
	mkdir -p ${deploydir}/js
		
	cp -r ${htmldir}/* ${deploydir}/
	cp -r ${cssdir}/* ${deploydir}/css/
	cp -r ${jsdir}/* ${deploydir}/js/
	cp -r ${htmldir}/* ${deploydir}/
	cp -r ${pythondir}/* ${deploydir}
}

case $1 in
	start)
	echo "deploying urloggng.com locally"
	init
	
	echo "starting urlogging site locally, port - ${port}"
	${gaedir}/dev_appserver.py ${deploydir} -p ${port}
	;;
	
	push-gae)
		echo "urlogging.com@gmail.com start to push ${component} into google appengine."
		init
		${gaedir}/appcfg.py update ${deploydir} --email=urlogging.com@gmail.com --passin
	;;	
	
esac